<?php
namespace app\model;

use app\util\Tools;

class UserMoneyLog extends Base{
    protected $autoWriteTimestamp = true;
    protected $resultSetType = 'collection';
    protected $updateTime = 'update_time';
    protected $createTime = 'addtime';

    public function getOrdertypeTextAttr($value,$data) {
        $status = ['1' => '奖励','4'=>'提现'];

        return $status[$data['ordertype']];
    }

    public function getTurnoverTextAttr($value,$data) {
        $status = ['-1' => '支出','1'=> '收入'];

        return $status[$data['turnover']];
    }

    public function getaddtimeAttr($value) {
        return $value ? date("Y-m-d H:i:s", $value) : '';
    }

    public function getamountAttr($value) {
        return Tools::bcCalculate($value, 100, '/');
    }

    public function setamountAttr($value) {
        return $value * 100;
    }

    public function getbalanceAttr($value) {
        return Tools::bcCalculate($value, 100, '/');
    }

    public function setbalanceAttr($value) {
        return $value * 100;
    }
}

?>
